from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response

class CustomPageNumberPagination(PageNumberPagination):
    page_size = 10  # 每页显示 10 条记录
    page_size_query_param = 'page_size'
    max_page_size = 100

    def get_paginated_response(self, data):
        return Response({
            'results': data,
            'total_pages': self.page.paginator.num_pages,  # 添加总页数
            'current_page': self.page.number,  # 添加当前页码
            'total_records': self.page.paginator.count,  # 添加总记录数
        })